﻿@using Smartstore.Licensing
@using Smartstore.Admin.Models.Modularity

@model LicenseLabelModel

@{
    Layout = null;

    if (!Model.IsLicensable || Model.HideLabel)
    {
        return;
    }
}

@if (Model.LicenseState == LicensingState.Licensed)
{
    <span class="badge badge-success">@T("Admin.Common.Licensed")</span>
}
else if (Model.LicenseState == LicensingState.Unlicensed && Model.TruncatedLicenseKey.HasValue())
{
    <span class="badge badge-danger">@T("Admin.Common.Unlicensed")</span>
}
else
{
    var remainingDaysLabel = "badge-success";
    if (Model.RemainingDemoUsageDays.HasValue)
    {
        if (Model.RemainingDemoUsageDays <= 3)
        {
            remainingDaysLabel = "badge-dark";
        }
        else if (Model.RemainingDemoUsageDays <= 6)
        {
            remainingDaysLabel = "badge-warning";
        }
    }

    <span class="badge @remainingDaysLabel">
        @if (!Model.RemainingDemoUsageDays.HasValue)
        {
            @T("Admin.Plugins.LicensingDemoNotStarted")
        }
        else if (Model.RemainingDemoUsageDays <= 0)
        {
            @T("Admin.Plugins.LicensingDemoExpired")
        }
        else
        {
            @T("Admin.Plugins.LicensingDemoRemainingDays", Model.RemainingDemoUsageDays)
        }
    </span>
}